<?php


abstract class BaseRingtoneOriginPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'ringtone_origin';

	
	const CLASS_DEFAULT = 'lib.model.RingtoneOrigin';

	
	const NUM_COLUMNS = 33;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'ringtone_origin.ID';

	
	const NAME = 'ringtone_origin.NAME';

	
	const USER_ID = 'ringtone_origin.USER_ID';

	
	const SONG_ID = 'ringtone_origin.SONG_ID';

	
	const BEAT_ID = 'ringtone_origin.BEAT_ID';

	
	const SONG_NAME = 'ringtone_origin.SONG_NAME';

	
	const FILE_PATH = 'ringtone_origin.FILE_PATH';

	
	const CLIP_ID = 'ringtone_origin.CLIP_ID';

	
	const FILE_PATH_WAV = 'ringtone_origin.FILE_PATH_WAV';

	
	const SPECTRUM_PATH = 'ringtone_origin.SPECTRUM_PATH';

	
	const SPECTRUM_WIDTH = 'ringtone_origin.SPECTRUM_WIDTH';

	
	const CATEGORY_ID = 'ringtone_origin.CATEGORY_ID';

	
	const ARTIST1_ID = 'ringtone_origin.ARTIST1_ID';

	
	const ARTIST1_NAME = 'ringtone_origin.ARTIST1_NAME';

	
	const ARTIST2_ID = 'ringtone_origin.ARTIST2_ID';

	
	const ARTIST2_NAME = 'ringtone_origin.ARTIST2_NAME';

	
	const ARTIST3_ID = 'ringtone_origin.ARTIST3_ID';

	
	const ARTIST3_NAME = 'ringtone_origin.ARTIST3_NAME';

	
	const COMPOSER_ID = 'ringtone_origin.COMPOSER_ID';

	
	const COMPOSER_NAME = 'ringtone_origin.COMPOSER_NAME';

	
	const ALBUM_ID = 'ringtone_origin.ALBUM_ID';

	
	const ALBUM_NAME = 'ringtone_origin.ALBUM_NAME';

	
	const TRACK_NO = 'ringtone_origin.TRACK_NO';

	
	const GENRE = 'ringtone_origin.GENRE';

	
	const LYRICS = 'ringtone_origin.LYRICS';

	
	const BITRATE = 'ringtone_origin.BITRATE';

	
	const DURATION = 'ringtone_origin.DURATION';

	
	const CREATED_DATETIME = 'ringtone_origin.CREATED_DATETIME';

	
	const REMARK = 'ringtone_origin.REMARK';

	
	const CHECKNUM = 'ringtone_origin.CHECKNUM';

	
	const CONVERT_SONG_ID = 'ringtone_origin.CONVERT_SONG_ID';

	
	const ORIGIN_STATUS = 'ringtone_origin.ORIGIN_STATUS';

	
	const IS_UPLOAD = 'ringtone_origin.IS_UPLOAD';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'UserId', 'SongId', 'BeatId', 'SongName', 'FilePath', 'ClipId', 'FilePathWav', 'SpectrumPath', 'SpectrumWidth', 'CategoryId', 'Artist1Id', 'Artist1Name', 'Artist2Id', 'Artist2Name', 'Artist3Id', 'Artist3Name', 'ComposerId', 'ComposerName', 'AlbumId', 'AlbumName', 'TrackNo', 'Genre', 'Lyrics', 'Bitrate', 'Duration', 'CreatedDatetime', 'Remark', 'Checknum', 'ConvertSongId', 'OriginStatus', 'IsUpload', ),
		BasePeer::TYPE_COLNAME => array (RingtoneOriginPeer::ID, RingtoneOriginPeer::NAME, RingtoneOriginPeer::USER_ID, RingtoneOriginPeer::SONG_ID, RingtoneOriginPeer::BEAT_ID, RingtoneOriginPeer::SONG_NAME, RingtoneOriginPeer::FILE_PATH, RingtoneOriginPeer::CLIP_ID, RingtoneOriginPeer::FILE_PATH_WAV, RingtoneOriginPeer::SPECTRUM_PATH, RingtoneOriginPeer::SPECTRUM_WIDTH, RingtoneOriginPeer::CATEGORY_ID, RingtoneOriginPeer::ARTIST1_ID, RingtoneOriginPeer::ARTIST1_NAME, RingtoneOriginPeer::ARTIST2_ID, RingtoneOriginPeer::ARTIST2_NAME, RingtoneOriginPeer::ARTIST3_ID, RingtoneOriginPeer::ARTIST3_NAME, RingtoneOriginPeer::COMPOSER_ID, RingtoneOriginPeer::COMPOSER_NAME, RingtoneOriginPeer::ALBUM_ID, RingtoneOriginPeer::ALBUM_NAME, RingtoneOriginPeer::TRACK_NO, RingtoneOriginPeer::GENRE, RingtoneOriginPeer::LYRICS, RingtoneOriginPeer::BITRATE, RingtoneOriginPeer::DURATION, RingtoneOriginPeer::CREATED_DATETIME, RingtoneOriginPeer::REMARK, RingtoneOriginPeer::CHECKNUM, RingtoneOriginPeer::CONVERT_SONG_ID, RingtoneOriginPeer::ORIGIN_STATUS, RingtoneOriginPeer::IS_UPLOAD, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'user_id', 'song_id', 'beat_id', 'song_name', 'file_path', 'clip_id', 'file_path_wav', 'spectrum_path', 'spectrum_width', 'category_id', 'artist1_id', 'artist1_name', 'artist2_id', 'artist2_name', 'artist3_id', 'artist3_name', 'composer_id', 'composer_name', 'album_id', 'album_name', 'track_no', 'genre', 'lyrics', 'bitrate', 'duration', 'created_datetime', 'remark', 'checknum', 'convert_song_id', 'origin_status', 'is_upload', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'UserId' => 2, 'SongId' => 3, 'BeatId' => 4, 'SongName' => 5, 'FilePath' => 6, 'ClipId' => 7, 'FilePathWav' => 8, 'SpectrumPath' => 9, 'SpectrumWidth' => 10, 'CategoryId' => 11, 'Artist1Id' => 12, 'Artist1Name' => 13, 'Artist2Id' => 14, 'Artist2Name' => 15, 'Artist3Id' => 16, 'Artist3Name' => 17, 'ComposerId' => 18, 'ComposerName' => 19, 'AlbumId' => 20, 'AlbumName' => 21, 'TrackNo' => 22, 'Genre' => 23, 'Lyrics' => 24, 'Bitrate' => 25, 'Duration' => 26, 'CreatedDatetime' => 27, 'Remark' => 28, 'Checknum' => 29, 'ConvertSongId' => 30, 'OriginStatus' => 31, 'IsUpload' => 32, ),
		BasePeer::TYPE_COLNAME => array (RingtoneOriginPeer::ID => 0, RingtoneOriginPeer::NAME => 1, RingtoneOriginPeer::USER_ID => 2, RingtoneOriginPeer::SONG_ID => 3, RingtoneOriginPeer::BEAT_ID => 4, RingtoneOriginPeer::SONG_NAME => 5, RingtoneOriginPeer::FILE_PATH => 6, RingtoneOriginPeer::CLIP_ID => 7, RingtoneOriginPeer::FILE_PATH_WAV => 8, RingtoneOriginPeer::SPECTRUM_PATH => 9, RingtoneOriginPeer::SPECTRUM_WIDTH => 10, RingtoneOriginPeer::CATEGORY_ID => 11, RingtoneOriginPeer::ARTIST1_ID => 12, RingtoneOriginPeer::ARTIST1_NAME => 13, RingtoneOriginPeer::ARTIST2_ID => 14, RingtoneOriginPeer::ARTIST2_NAME => 15, RingtoneOriginPeer::ARTIST3_ID => 16, RingtoneOriginPeer::ARTIST3_NAME => 17, RingtoneOriginPeer::COMPOSER_ID => 18, RingtoneOriginPeer::COMPOSER_NAME => 19, RingtoneOriginPeer::ALBUM_ID => 20, RingtoneOriginPeer::ALBUM_NAME => 21, RingtoneOriginPeer::TRACK_NO => 22, RingtoneOriginPeer::GENRE => 23, RingtoneOriginPeer::LYRICS => 24, RingtoneOriginPeer::BITRATE => 25, RingtoneOriginPeer::DURATION => 26, RingtoneOriginPeer::CREATED_DATETIME => 27, RingtoneOriginPeer::REMARK => 28, RingtoneOriginPeer::CHECKNUM => 29, RingtoneOriginPeer::CONVERT_SONG_ID => 30, RingtoneOriginPeer::ORIGIN_STATUS => 31, RingtoneOriginPeer::IS_UPLOAD => 32, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'user_id' => 2, 'song_id' => 3, 'beat_id' => 4, 'song_name' => 5, 'file_path' => 6, 'clip_id' => 7, 'file_path_wav' => 8, 'spectrum_path' => 9, 'spectrum_width' => 10, 'category_id' => 11, 'artist1_id' => 12, 'artist1_name' => 13, 'artist2_id' => 14, 'artist2_name' => 15, 'artist3_id' => 16, 'artist3_name' => 17, 'composer_id' => 18, 'composer_name' => 19, 'album_id' => 20, 'album_name' => 21, 'track_no' => 22, 'genre' => 23, 'lyrics' => 24, 'bitrate' => 25, 'duration' => 26, 'created_datetime' => 27, 'remark' => 28, 'checknum' => 29, 'convert_song_id' => 30, 'origin_status' => 31, 'is_upload' => 32, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/RingtoneOriginMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.RingtoneOriginMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = RingtoneOriginPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(RingtoneOriginPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(RingtoneOriginPeer::ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::USER_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::SONG_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::BEAT_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::SONG_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::FILE_PATH);

		$criteria->addSelectColumn(RingtoneOriginPeer::CLIP_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::FILE_PATH_WAV);

		$criteria->addSelectColumn(RingtoneOriginPeer::SPECTRUM_PATH);

		$criteria->addSelectColumn(RingtoneOriginPeer::SPECTRUM_WIDTH);

		$criteria->addSelectColumn(RingtoneOriginPeer::CATEGORY_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST1_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST1_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST2_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST2_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST3_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ARTIST3_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::COMPOSER_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::COMPOSER_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::ALBUM_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ALBUM_NAME);

		$criteria->addSelectColumn(RingtoneOriginPeer::TRACK_NO);

		$criteria->addSelectColumn(RingtoneOriginPeer::GENRE);

		$criteria->addSelectColumn(RingtoneOriginPeer::LYRICS);

		$criteria->addSelectColumn(RingtoneOriginPeer::BITRATE);

		$criteria->addSelectColumn(RingtoneOriginPeer::DURATION);

		$criteria->addSelectColumn(RingtoneOriginPeer::CREATED_DATETIME);

		$criteria->addSelectColumn(RingtoneOriginPeer::REMARK);

		$criteria->addSelectColumn(RingtoneOriginPeer::CHECKNUM);

		$criteria->addSelectColumn(RingtoneOriginPeer::CONVERT_SONG_ID);

		$criteria->addSelectColumn(RingtoneOriginPeer::ORIGIN_STATUS);

		$criteria->addSelectColumn(RingtoneOriginPeer::IS_UPLOAD);

	}

	const COUNT = 'COUNT(ringtone_origin.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT ringtone_origin.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtoneOriginPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtoneOriginPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = RingtoneOriginPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = RingtoneOriginPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return RingtoneOriginPeer::populateObjects(RingtoneOriginPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			RingtoneOriginPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = RingtoneOriginPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return RingtoneOriginPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(RingtoneOriginPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(RingtoneOriginPeer::ID);
			$selectCriteria->add(RingtoneOriginPeer::ID, $criteria->remove(RingtoneOriginPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(RingtoneOriginPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(RingtoneOriginPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof RingtoneOrigin) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(RingtoneOriginPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(RingtoneOrigin $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(RingtoneOriginPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(RingtoneOriginPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(RingtoneOriginPeer::DATABASE_NAME, RingtoneOriginPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = RingtoneOriginPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(RingtoneOriginPeer::DATABASE_NAME);

		$criteria->add(RingtoneOriginPeer::ID, $pk);


		$v = RingtoneOriginPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(RingtoneOriginPeer::ID, $pks, Criteria::IN);
			$objs = RingtoneOriginPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseRingtoneOriginPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/RingtoneOriginMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.RingtoneOriginMapBuilder');
}
